<?php
/**
 * 详情
 *
 * @url
 */
	$goodsid = intval($_GPC['goodsid']);
	$goods = pdo_fetch("SELECT * FROM ".tablename('shopping3_goods')." WHERE weid={$weid} and  id = {$goodsid}");
	if (empty($goods)) {
		message('抱歉，商品不存在或是已经被删除！',"","ajax");
	}else{
		if(!empty($goods['thumb_url'])){
			$goods['thumbArr']=explode('|',$goods['thumb_url']);	
 		}else{
			$goods['thumbArr']=array($goods['thumb']);
		}
		
	}
    $rdata=array("main"=>"","addtion"=>"","other"=>"");
    $rdata["title"]=$goods["title"];
    $rdata["thumb"]=$goods["thumb"];
    
    $rdata["unit"]=$goods["unit"];
    
    
    $rdata["description"]=$goods["description"];
    $rdata["content"]=trim(strip_tags($goods["content"]));
    $rdata["goodssn"]=$goods["goodssn"];
    $rdata["marketprice"]=$goods["marketprice"];
    $rdata["productprice"]=$goods["productprice"];
    
    
    

    
    
    
    $metlist=pdo_fetchall("SELECT m.id,m.title,g.mettype FROM ".tablename('goods_items')." g,".tablename('material')." m where m.id=g.mid and g.tid={$goodsid} order by g.mettype");
    $templist=array();
    while(list($k,$v)=each($metlist)){
        $mtype=$v["mettype"];
        
        $templist[$mtype][]=$v["title"];
    }
    
    while(list($k,$v)=each($templist)){
        if($k==1){
            $rdata["main"]=implode(",",$v);
        }elseif($k==2){
            $rdata["addtion"]=implode(",",$v);
        }elseif($k==3){
            $rdata["other"]=implode(",",$v);
        }
    
    }
    
    $rdata["metlist"]=$metnewlist;
    
	pdo_update('shopping3_goods',array('hits'=>$goods['hits']+1),array('id'=>$goods['id']));
    
	echo json_encode($rdata);
	exit;
        
?>
